package com.cute.leetcode.editor.cn.my;

/**
 *  冒泡排序: 冒泡排序的规则是相邻两个比较,大的上浮
 */
public class BubbleSort {

    public static void main(String[] args) {
        int[] a = {2, 1, 10, 4, 7, 6, 5, 8, 9, 3};

        for (int i=0;i<a.length;i++){
            for (int start=i,end=start+1;start<=end&&end<a.length;){
                int tmp;
                if(a[start]>a[end]){
                    tmp=a[end];
                    a[end]=a[start];
                    a[start]=tmp;
                }
                start=i+1;
                end=end+1;
            }
        }

        System.out.println(a);
    }
}
